//
//  DMineViewController.m
//  dance
//
//  Created by aether on 2023/10/19.
//

#import "DMineViewController.h"
#import "DRelationViewController.h"
#import "DProtocolViewController.h"
#import "DAboutViewController.h"
#import "DMoreViewController.h"
#import "DMineCell.h"

@interface DMineViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) IBOutlet UITableView *table;
@property (nonatomic, strong) NSArray *items;

@end

@implementation DMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initValues];
    [self initViews];
}

- (void) initValues {
    self.items = @[@"联系客服", @"用户协议", @"隐私协议", @"设置"];
}

- (void) initViews {
    self.title = @"我的";
    [self.table registerNib:[UINib nibWithNibName:@"DMineCell" bundle:nil] forCellReuseIdentifier:@"DMineCell"];
}

#pragma mark - TableView 代理方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.items count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 61;
}
//单元格内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DMineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DMineCell" forIndexPath:indexPath];
    [cell setName:[self.items objectAtIndex:indexPath.row]];
    
    return cell;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        DRelationViewController *dinfo = [[DRelationViewController alloc] initWithNibName:@"DRelationViewController" bundle:nil];
        [self.navigationController pushViewController:dinfo animated:YES];
    } else if (indexPath.row == 1 || indexPath.row == 2) {
        DProtocolViewController *dinfo = [[DProtocolViewController alloc] initWithNibName:@"DProtocolViewController" bundle:nil];
        [dinfo setName:[self.items objectAtIndex:indexPath.row]];
        [self.navigationController pushViewController:dinfo animated:YES];
    } else if (indexPath.row == 3) {
//        DAboutViewController *dinfo = [[DAboutViewController alloc] initWithNibName:@"DAboutViewController" bundle:nil];
//        [self.navigationController pushViewController:dinfo animated:YES];
        DMoreViewController *dinfo = [[DMoreViewController alloc] initWithNibName:@"DMoreViewController" bundle:nil];
        [self.navigationController pushViewController:dinfo animated:YES];
    }
}

#pragma mark - 获取设置


@end
